package repproyectobases;
import javax.swing.table.DefaultTableModel;
/**
*  @web http://jc-mouse.blogspot.com/
 * @author Mouse
 */
public class Clientes extends javax.swing.JInternalFrame {
    private Control ctrl;
    private Object[][] dtClientes;    

    /** Creates new form Clientes */
    public Clientes(Control ctrl) {
        initComponents();
        this.ctrl = ctrl;
        this.setTitle("Clientes Registrados - By Luis&Luis");
        updateTabla();
    }

    /* actualiza el objeto tabla con informacion de la base de datos */
    private void updateTabla(){
        //actualiza los datos de la tabla realizando una consulta a la base de datos
        String[] columNames = {"id Cliente","Nombre Completo","Direccion","Telefono"};
        //nombre de columnas, tabla, instruccion sql
        dtClientes = ctrl.getClientes();
        // se colocan los datos en la tabla
        DefaultTableModel datos = new DefaultTableModel(dtClientes,columNames);
        tabla.setModel(datos);
}

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tabla = new javax.swing.JTable();

        setClosable(true);

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tabla);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 385, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 395, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabla;
    // End of variables declaration//GEN-END:variables

}
